package com.klaus.ohMySpace.service.Impl;

import com.klaus.ohMySpace.dao.BaseDao;
import com.klaus.ohMySpace.entity.BasicEntity;
import com.klaus.ohMySpace.service.BaseService;
import org.hibernate.criterion.DetachedCriteria;

import java.util.List;

/**
 * Created by Mklaus on 15/8/7.
 */
public class BaseServiceImpl<T extends BasicEntity> implements BaseService<T>  {

    public BaseDao getBaseDao(){
        return null;
    }

    @Override
    public void add(T t) {
        getBaseDao().save(t);
    }

    @Override
    public void delete(int id) {
        getBaseDao().delete(id);
    }

    @Override
    public void delete(T t) {
        getBaseDao().delete(t);
    }

    @Override
    public void update(T t) {
        getBaseDao().update(t);
    }

    @Override
    public T get(int id) {
        return (T)getBaseDao().get(id);
    }

    @Override
    public List<T> getAll() {
        return getBaseDao().getAll();
    }

    @Override
    public List<T> get(DetachedCriteria dc) {
        return getBaseDao().search(dc);
    }

    @Override
    public List<T> get(DetachedCriteria dc, int start, int size) {
        return getBaseDao().search(dc,start,size);
    }
}
